package com.lengtouzai.databaseexp.security;

import io.jmix.core.entity.KeyValueEntity;
import io.jmix.security.model.EntityAttributePolicyAction;
import io.jmix.security.model.EntityPolicyAction;
import io.jmix.security.role.annotation.EntityAttributePolicy;
import io.jmix.security.role.annotation.EntityPolicy;
import io.jmix.security.role.annotation.ResourceRole;
import io.jmix.security.role.annotation.SpecificPolicy;
import io.jmix.securityflowui.role.annotation.MenuPolicy;
import io.jmix.securityflowui.role.annotation.ViewPolicy;

@ResourceRole(name = "DefaultAccessRole", code = DefaultAccessRole.CODE)
public interface DefaultAccessRole {
    String CODE = "default-access-role";

    @ViewPolicy(viewIds = {
            "exp_MainView",
            "exp_PersonalView",
            "exp_EducationalExperience.list",
            "exp_EducationalExperience.detail",
            "exp_WorkExperience.list",
            "exp_WorkExperience.detail",
            "exp_FriendGroup.list",
            "exp_FriendGroup.detail",
            "exp_Friend.list",
            "exp_NewFriendView",
            "exp_SelectFriendView",
            "exp_PersonalJournalView"})
    void main();

    @MenuPolicy(menuIds = {
            "exp_PersonalView",
            "exp_EducationalExperience.list",
            "exp_WorkExperience.list",
            "exp_FriendGroup.list",
            "exp_Friend.list",
            "exp_PersonalJournalView"})
    void menu();

    @ViewPolicy(viewIds = "exp_LoginView")
    @SpecificPolicy(resources = "ui.loginToUi")
    void login();

    @EntityPolicy(entityClass = KeyValueEntity.class, actions = EntityPolicyAction.READ)
    @EntityAttributePolicy(entityClass = KeyValueEntity.class, attributes = "*", action = EntityAttributePolicyAction.VIEW)
    void keyValueEntity();

    @EntityPolicy(entityName = "*", actions = EntityPolicyAction.ALL)
    @EntityAttributePolicy(entityName = "*", attributes = "*", action = EntityAttributePolicyAction.MODIFY)
    void entity();
}